<{if $poll && !$poll.hasExpired && !$poll.hasVoted && $poll.hasStarted}>
	<div class="icmspoll_singlepoll">
		    <h2>
			<{$poll.question}>
			<{if $poll.userCanEditAndDelete}>
				(<{$poll.editItemLink}>
				<{$poll.deleteItemLink}>)
			<{/if}>
		    </h2>
		<div class="singlepoll_description">
			<p style="font-size:80%;">
			    <{if $icms_isuser}><{$smarty.const._CO_ICMSPOLL_PRESENT_BY_USERPROFILE}> : <a href="<{$icms_url}>userinfo.php?uid=<{$icms_userid}>" title="<{$smarty.const._CO_ICMSPOLL_POLLS_VISIT_USERPROFILE}>"><{$icms_uname}></a>&nbsp;|&nbsp;<{/if}>
			<{$smarty.const._CO_ICMSPOLL_POLL_ENDS_ON}>&nbsp;:&nbsp;<{$poll.end_time}>
			</p>
			<p>&nbsp;</p>
			<{if $poll.dsc}>
			    <p><{$poll.dsc}></p>
			    <p>&nbsp;</p>
			<{/if}>
		</div>

		<div class="singlepoll_form">
			<form id="pollform_<{$poll.id}>" name="pollform_<{$poll.id}>" class="icmspoll_pollform" action="<{$icmspoll_url}>submitpoll.php" method="post">
				    <div class="option_set">
    					<{foreach item=option from=$options name=options}>
    						<div class="icmspoll_option_<{$option.color}> icmspoll_option_design">
    							<label><input style="float:left;" id="poll_option_<{$option.id}>" class="icmspoll_option_<{$option.inputtype}>" type="<{$poll.inputtype}>" name="poll_option<{if $poll.isMultiple}>[]<{/if}>" value="<{$option.id}>" <{if $smarty.foreach.options.first}>checked<{/if}> />
    							<span style="float:left;padding-top:6px;padding-left: 3px;"><{$option.text}></span>
	    						<{if $option.userCanEditAndDelete}>
									<span style="float:left;padding-top:6px;padding-left: 3px;" class="options_buttonbar">
										(<{$option.editItemLink}>
										<{$option.deleteItemLink}>)
									</span>
								<{/if}>
								<{$poll.delimeter}>
							</label>
						</div>
    					<{/foreach}>
    				</div>
				<{if $poll.hasVoted}>
					<div class="box">
						<input type="submit" readonly class="btnpoll icmspoll" value="<{$smarty.const._MD_ICMSPOLL_POLLS_ALREADYVOTED}>" />
					</div>
				<{elseif !$poll.hasVoted && $poll.voteAccessGranted}>
					<div class="box">
						<input id="submit_poll_<{$poll.id}>" name="submit_poll_<{$poll.id}>" type="submit" class="btnpoll icmspoll" value="<{$smarty.const._MD_ICMSPOLL_POLLS_SUBMIT}>" /><span class="helper"></span>
					</div>
				<{else}>
				<{/if}>
			</form>
		</div>
	</div>
<{elseif $poll && $poll.hasExpired || $poll.hasVoted}>
	<div class="icmspoll_singlepoll">
		<h2>
			<{$poll.question}>
			<{if $poll.userCanEditAndDelete}>
				(<{$poll.editItemLink}>
				<{$poll.deleteItemLink}>)
			<{/if}>
		</h2>
		<div class="singlepoll_description">
			
			<p style="font-size:80%;"><{if $icms_isuser}><{$smarty.const._CO_ICMSPOLL_PRESENT_BY_USERPROFILE}> : <a href="<{$icms_url}>userinfo.php?uid=<{$icms_userid}>" title="<{$smarty.const._CO_ICMSPOLL_POLLS_VISIT_USERPROFILE}>"><{$icms_uname}></a>&nbsp;|&nbsp; <{/if}><{$smarty.const._CO_ICMSPOLL_POLLS_VOTES_UNTIL_NOW}> : <{$total_votes}>&nbsp;|&nbsp; <{$smarty.const._CO_ICMSPOLL_POLL_ENDS_ON}>&nbsp;:&nbsp;<{$poll.end_time}></p>
			<{if $poll.dsc}>
			    <p>&nbsp;</p>
			    <p><{$poll.dsc}></p>
			    <p>&nbsp;</p>
			<{/if}>
		</div>

		<div class="singlepoll_form">
		    <div class="poll_result">
		    	<div class="icmspoll_result_options">
	    			<{foreach item=option from=$options name=options}>
				<div class="poll_option_txt">
					<{$option.text}> <small class="span_poll_result">(<{$option.result}>, <{$option.total_votes}> <{$smarty.const._CO_ICMSPOLL_OPTION_TOTALVOTES}>)</small>
				</div>
				<div class="icmspoll_clear_left">&nbsp;</div>
	    				<div class="result_option">
	    				   <div class="icmspoll_option_<{$option.color}> icmspoll_option_color" style="width:<{$option.result}>" >
	    				       &nbsp;
	    				   </div>
	                    </div>
	    				<{$poll.delimeter}>
	    			<{/foreach}>
    			</div>
    		</div>
    		<div class="icmspoll_clear_left">&nbsp;</div>
			<{if $poll.hasVoted && !$poll.hasExpired}>
				<div class="box">
					<input id="submit_poll_<{$poll.id}>" type="submit" readonly class="btnpoll voted icmspoll_voted" value="<{$smarty.const._MD_ICMSPOLL_POLLS_ALREADYVOTED}>" />
					<div class="icmspoll_morelink">
					<{if $icms_isuser}>
					    <span class="more_polls_by"><a href="<{$icmspoll_url}>index.php?op=getPollsByCreator&uid=<{$poll.user_id}>"><img src="<{$icmspoll_images_url}>other-user-poll.png" title="<{$smarty.const._CO_ICMSPOLL_POLLS_GET_MORE_BY_USER}> <{$icms_uname}>" /></a>&nbsp;&nbsp;</span>
					<{/if}>
					<{if $user_can_submit}>
					    <span class="more_polls_by">
						<a href="<{$icmspoll_url}>polls.php?op=mod" title="<{$smarty.const._MD_ICMSPOLL_SUBMIT_POLL}>">
							<img src="<{$icmspoll_images_url}>add_poll_now.png" alt="<{$smarty.const._MD_ICMSPOLL_SUBMIT_POLL}>" title="<{$smarty.const._MD_ICMSPOLL_SUBMIT_POLL}>" />
						</a>
					</span>
					<{/if}>
					</div>
				</div>
			<{/if}>
		</div>
	</div>

<{/if}>
<div id="icmspoll_alert" style="display: none;">&nbsp;</div>
<script type="text/javascript">
	$(document).ready(function(){
		$("#submit_poll_<{$poll.id}>").click(function(e) {
			e.preventDefault();
			$("#pollform_<{$poll.id}>").submit();
			return false;
		});

		$("#pollform_<{$poll.id}>").submit(function(e) {
			e.preventDefault();
			$.ajax({
				url: $("#pollform_<{$poll.id}>").attr("action"),
				type: "POST",
				dataType: "json",
				data: {
					poll_id: '<{$poll.id}>',
					op: 'vote',
					poll_option: $("#pollform_<{$poll.id}> input[type=<{$poll.inputtype}>]:checked").map(function(){return this.value;}).get().join(",")
				},
				success: function(response) {
					var pollform = "pollform_<{$poll.id}>";
					if(response.status === "success") {
						document.forms.pollform_<{$poll.id}>.reset();
						$("#icmspoll_alert").html(response.message);
						$("#icmspoll_alert").dialog("open");
					} else if(response.status === "error") {
						document.forms.pollform_<{$poll.id}>.reset();
						$("#icmspoll_alert").html(response.message);
						$("#icmspoll_alert").dialog("open");
					}
				}

			})
		});

		$("#icmspoll_alert").dialog({
			autoOpen: false,
			modal: true,
			hide: "clip",
			show: "clip",
			resizable: false,
			width: 800,
			height: "auto",
			buttons: {
				Ok: function() {
					$("#icmspoll_alert").html("");
					$(this).dialog( "close" );
					window.location.reload();
				}
			}
		});
	});
</script>
